import 'package:acgn_pioneer/public.dart';
import 'package:acgn_pioneer/widgets/reader/mixins/_index.dart';
import 'package:flutter/widgets.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';

import '_index.dart';

/// 简约弹幕提示
class ReaderBarrageMenu extends StatefulWidget {
  ReaderBarrageMenu({Key key}) : super(key: key);

  @override
  ReaderBarrageMenuState createState() => new ReaderBarrageMenuState();
}

class ReaderBarrageMenuState extends State<ReaderBarrageMenu>
    with ReaderWidgetBase {
  bool isShowDm = false;

  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Row(children: buildMenu()
        //  buildMenu(),
        // buildSimple
        );
  }

  buildMenu() {
    List<Widget> list = [
      GestureDetector(
        onTap: () {
          isShowDm = !isShowDm;
          setState(() {});
        },
        child:
            SVG.svg(isShowDm ? 'reader_dm_open' : 'reader_dm_close', size: 30),
      ),
      SizedBox(width: 6),
      GestureDetector(
        onTap: () {
          showMaterialModalBottomSheet(
              backgroundColor: Colors.transparent,
              enableDrag: false,
              context: context,
              builder: (context) => ReaderBarrageSetting(
                  barrageController: readerPage.barrageController));
        },
        child: SVG.svg('reader_dm_set', size: 30),
      ),
      Expanded(
          child: GestureDetector(
              onTap: () {
                showMaterialModalBottomSheet(
                    backgroundColor: ColorUtil.rgba(27, 27, 38, 1),
                    enableDrag: false,
                    context: context,
                    builder: (context) => PopInputBoxComponent(
                            child: ReaderBarrageInput(
                          userModel: this.user,
                          comicId: readModel.comicId,
                          chapterId: readModel.currentChapter.id,
                          imgIndex: readModel.currentImageIndex,
                          barrageController: readerPage.barrageController,
                        )));
              },
              child: Container(
                  width: double.infinity,
                  height: 32,
                  margin: EdgeInsets.only(left: 16, right: 4),
                  padding: EdgeInsets.only(left: 16, right: 16),
                  decoration: BoxDecoration(
                      color: ColorUtil.rgba(255, 255, 255, 0.35),
                      borderRadius: BorderRadius.all(Radius.circular(16))),
                  child: Text(
                    '弹幕发送准备中（づ￣3￣）づ',
                    style: TextStyle(
                        color: ColorUtil.rgba(255, 255, 255, 0.6),
                        fontSize: 12,
                        height: 2),
                  ))))
    ];
    return list;
  }

  buildSimple() {
    List<Widget> list = [
      GestureDetector(
          onTap: () {
            isShowDm = !isShowDm;
            setState(() {});
          },
          child: Container(
              padding: EdgeInsets.only(left: 10, right: 10),
              height: 28,
              child: Row(
                children: [
                  SVG.svg(isShowDm ? 'reader_dmck_cli' : 'reader_dmck',
                      size: 18),
                  Text(
                    "弹幕 233",
                    style:
                        TextStyle(color: Colors.white, fontSize: 12, height: 1),
                  )
                ],
              ),
              decoration: BoxDecoration(
                  color: ColorUtil.rgba(0, 0, 0, 0.5),
                  borderRadius: BorderRadius.all(Radius.circular(16)))))
    ];

    return list;
  }
}
